<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CAD Simple Viewer Example</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }

      body {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        background: #f5f5f5;
        height: 100vh;
        overflow: hidden;
      }

      .file-input-container {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: 10;
        display: flex;
        flex-direction: column;
        align-items: center;
        pointer-events: none;
        transition: all 0.3s ease;
      }
      
      .file-input-container.loaded {
        top: 2rem;
        left: 2rem;
        transform: none;
      }
      
      .file-fab {
        pointer-events: auto;
        background: #23272f;
        color: #e0e0e0;
        border: none;
        border-radius: 12px;
        width: 80px;
        height: 64px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 8px rgba(0,0,0,0.18);
        cursor: pointer;
        transition: all 0.3s ease;
        outline: none;
        padding: 0;
        position: relative;
      }
      
      .file-input-container.loaded .file-fab {
        width: 40px;
        height: 32px;
      }
      
      .file-fab:hover {
        background: #353b45;
        box-shadow: 0 4px 16px rgba(0,0,0,0.22);
      }
      .file-fab input[type="file"] {
        display: none;
      }
      .file-fab-label {
        margin-top: 0.5rem;
        color: #fff;
        font-size: 1.2rem;
        text-align: center;
        text-shadow: 0 1px 4px rgba(0,0,0,0.18);
        transition: all 0.3s ease;
      }
      
      .file-input-container.loaded .file-fab-label {
        font-size: 1rem;
      }
      
      .file-icon {
        transition: all 0.3s ease;
      }
      
      .file-input-container.loaded .file-icon {
        width: 20px;
        height: 20px;
      }
      
      .file-fab svg {
        display: block;
        margin: 0 auto;
      }
      
      .button-group {
        display: flex;
        gap: 1.5rem;
        align-items: center;
      }
      
      .file-input-container.loaded .button-group {
        gap: 1rem;
      }
      
      .button-container {
        display: flex;
        flex-direction: column;
        align-items: center;
      }
      
      .file-input-container.hide {
        display: none;
      }

      .viewer-container {
        flex: 1;
        position: relative;
        background: #2c2c2c;
        overflow: hidden;
        width: 100vw;
        height: 100vh;
      }

      canvas {
        width: 100%;
        height: 100%;
        display: block;
      }

      .loading {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: white;
        font-size: 1.2rem;
        z-index: 5;
      }

      .spinner {
        width: 40px;
        height: 40px;
        border: 4px solid #333;
        border-top-color: #007bff;
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin: 0 auto 1rem;
      }

      @keyframes spin {
        to { transform: rotate(360deg); }
      }
    </style>
  </head>
  <body>
    <div class="viewer-container">
      <div class="file-input-container" id="fileInputContainer">
        <div class="button-group">
          <div class="button-container">
            <label class="file-fab" id="fileFab">
              <input type="file" id="fileInputElement" accept=".dxf,.dwg" />
              <svg width="40" height="40" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="file-icon">
                <path d="M3 6.5V15a1.5 1.5 0 0 0 1.5 1.5h11A1.5 1.5 0 0 0 17 15V7.5A1.5 1.5 0 0 0 15.5 6H7.414a1.5 1.5 0 0 1-1.06-.44l-1.414-1.414A1.5 1.5 0 0 0 4.586 4H4.5A1.5 1.5 0 0 0 3 5.5V6.5z"/>
                <path d="M8 11v2m0 0v-2m0 2h4m-4 0h4"/>
              </svg>
            </label>
            <div class="file-fab-label">Open</div>
          </div>
          <div class="button-container">
            <button class="file-fab" id="newDrawingButton">
              <svg width="40" height="40" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="file-icon">
                <path d="M10 3v14M3 10h14"/>
              </svg>
            </button>
            <div class="file-fab-label">New</div>
          </div>
        </div>
      </div>
      <div class="loading" id="loading" style="display: none;">
        <div class="spinner"></div>
        Loading CAD file...
      </div>
      <canvas id="canvas"></canvas>
    </div>
    <script type="module" src="/src/main.ts"></script>
  </body>
</html>